#include "common_input_msg.h"
#include "common_includes.h"

#define BUTTON_MSG_DEBUG_ENABLE
#ifdef BUTTON_MSG_DEBUG_ENABLE
#define BUTTON_MSG_DEBUG(...)  printf(__VA_ARGS__)
#else
#define BUTTON_MSG_DEBUG(...)  
#endif

COM_TASK_DEF(InputMsg);

static void common_input_msg_handler(Task task, MessageId id, Message msg)
{
    UNUSED(task);
    id = id;
    msg = msg;
	key_msg_t *key_msg = (key_msg_t *)msg;
	printf("PIO = 0x%x,key_action = 0x%x\n",key_msg->key_val,key_msg->action);
	switch (KEY_ACTION_DEF(key_msg->key_val,key_msg->action))
	{
		case KS_KEY_F:
		{
           // common_message_send(COMMON_MSG_TYPE_SYSTEM, EventSysScanNewRx, NULL, 0);
			//MessageSendLater(task, EventSysScanNewRx, 0, 0);
			printf("111111111111111111111EventSysScanNewRx\n");
			break;
		}
		
		case KD_KEY_F:
		{
                        //common_message_send(COMMON_MSG_TYPE_SYSTEM, EventUsrEnterPairing, NULL, 0);

			printf("22222222222222222EventSysScanNewRx\n");
			break;
		}		
		
		default:break;
	}
}

void common_input_message_init(void)
{
	COM_TASK_INIT(InputMsg, common_input_msg_handler);
}
